/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package kn.cstf2.transition.Server;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;

import kn.cstf2.global.Utils.CstF2Exception;
import kn.cstf2.global.db.Operations.OperacionesDB;
import kn.cstf2.transition.Bean.AsignIfownerStkBean;
import kn.cstf2.transition.Bean.DocumentsBean;
import kn.cstf2.transition.Bean.JoinPersonTransitionBean;
import kn.cstf2.transition.Bean.Localidad;
import kn.cstf2.transition.Bean.PersonalBean;
import kn.cstf2.transition.Bean.T_clientesDataFromStkBean;
import kn.cstf2.transition.Bean.TransitionBean;
import kn.cstf2.transition.Shared.TransitionShared;
import kn.mx.cstf2.sql.TransitionSql;



/**
 *
 * @author user1
 */
public class TransitionServer {

    OperacionesDB odb = new OperacionesDB();

    public void newTransition(int KnKey) {//78
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        String sentenciaSQL1 = "INSERT INTO t_transitions (knkey) VALUES (?)";
        String sentenciaSQL2 = "INSERT INTO joindocumenttransition (iddocument, idtransition) SELECT id, (SELECT id FROM t_transitions WHERE knkey = " + KnKey + ") FROM t_documents";
//        String sentenciaSQL3 = "INSERT INTO joinusertransition (iduser, idtransition) SELECT id, (SELECT id FROM t_transitions WHERE knkey = " + KnKey + ") FROM t_users WHERE su = TRUE";
        String sentenciaSQL4 = "INSERT INTO t_cop (idtransitioncop, export, attachedfiles) VALUES ((SELECT id FROM t_transitions WHERE knkey = " + KnKey + "), FALSE, 0)";
        String sentenciaSQL5 = "INSERT INTO t_cop (idtransitioncop, export, attachedfiles) VALUES ((SELECT id FROM t_transitions WHERE knkey = " + KnKey + "), TRUE, 0)";
        int index = 1;

        try {
            conn = odb.obtenerConexion("db");
            ps = conn.prepareStatement(sentenciaSQL1);
            ps.setInt(index++, KnKey);
            ps.execute();
            ps = conn.prepareStatement(sentenciaSQL2);
            ps.execute();
//            ps = conn.prepareStatement(sentenciaSQL3);
//            ps.execute();
            ps = conn.prepareStatement(sentenciaSQL4);
            ps.execute();
            ps = conn.prepareStatement(sentenciaSQL5);
            ps.execute();
        } catch (SQLException ex) {
            
            throw new CstF2Exception("Error al obtener el Usuario desde la base de datos");
        } finally {
            odb.cerrarResultSet(rs);
            odb.cerrarStatement(ps);
            odb.cerrarConnection(conn);
        }
    }

    public ArrayList<String> getSuperUsers() {
        ArrayList<String> resultado = new ArrayList<String>();

        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        String sentenciaSQL = "SELECT email FROM t_users WHERE su = TRUE";

        try {
            conn = odb.obtenerConexion("db");
            ps = conn.prepareStatement(sentenciaSQL);
            rs = ps.executeQuery();
            while (rs.next()) {
                resultado.add(rs.getString(1));
            }
        } catch (SQLException ex) {
            
            throw new CstF2Exception("Error al obtener el Usuario desde la base de datos");
        } finally {
            odb.cerrarResultSet(rs);
            odb.cerrarStatement(ps);
            odb.cerrarConnection(conn);
        }

        return resultado;
    }
    
    public ArrayList confirm(String locality){
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        Localidad localidad = new Localidad();
        String sentenciaSQL = "SELECT id FROM localidad WHERE nombre = ?";
        String sentenciaSQL1 = "SELECT t_users.email FROM t_users " +
                                "INNER JOIN localidad_usuario ON t_users.id = localidad_usuario.idusuario " +
                                "INNER JOIN localidad ON localidad_usuario.idlocalidad = localidad.id WHERE idlocalidad = ?";
        ArrayList<String> correos = new ArrayList<String>();

        try {
            conn = odb.obtenerConexion("db");
            ps = conn.prepareStatement(sentenciaSQL);
            ps.setString(1, locality);
            rs = ps.executeQuery();
            if (rs.next()) {
                localidad.setId(rs.getInt("id"));
            }
            
            ps = conn.prepareStatement(sentenciaSQL1);
            ps.setInt(1, localidad.getId());
            rs = ps.executeQuery();
            if(rs.next()){
                do{
                    String correo = rs.getString("email");
                    correo = correo.trim();
                    correos.add(correo);
                }while(rs.next());
            }
            
        } catch (SQLException ex) {
            
            throw new CstF2Exception("Error al obtener el Usuario desde la base de datos");
        } finally {
            odb.cerrarResultSet(rs);
            odb.cerrarStatement(ps);
            odb.cerrarConnection(conn);
        }
        return correos;
    }
    
    public ArrayList confirm2(String locality){
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        Localidad localidad = new Localidad();
        String sentenciaSQL = "SELECT id FROM localidad WHERE nombre = ?";
        String sentenciaSQL1 = "SELECT t_users.id FROM t_users " +
                                "INNER JOIN localidad_usuario ON t_users.id = localidad_usuario.idusuario " +
                                "INNER JOIN localidad ON localidad_usuario.idlocalidad = localidad.id WHERE idlocalidad = ?";
        ArrayList<Integer> ids = new ArrayList<Integer>();

        try {
            conn = odb.obtenerConexion("db");
            ps = conn.prepareStatement(sentenciaSQL);
            ps.setString(1, locality);
            rs = ps.executeQuery();
            if (rs.next()) {
                localidad.setId(rs.getInt("id"));
            }
            
            ps = conn.prepareStatement(sentenciaSQL1);
            ps.setInt(1, localidad.getId());
            rs = ps.executeQuery();
            if(rs.next()){
                do{
                    Integer id = rs.getInt("id");
                    ids.add(id);
                }while(rs.next());
            }
            
        } catch (SQLException ex) {
            
            throw new CstF2Exception("Error al obtener el Usuario desde la base de datos");
        } finally {
            odb.cerrarResultSet(rs);
            odb.cerrarStatement(ps);
            odb.cerrarConnection(conn);
        }
        return ids;
    }
    
    public void confirmated(Integer knkey){
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        String sentenciaSQL = "UPDATE t_transitions SET confirmated = true WHERE knkey = ?";
        
        try {
            conn = odb.obtenerConexion("db");
            ps = conn.prepareStatement(sentenciaSQL);
            ps.setInt(1, knkey);
            ps.executeUpdate();
            
        } catch (SQLException ex) {
            
            throw new CstF2Exception("Error al modificar el branch en la base de datos");
        } finally {
            odb.cerrarResultSet(rs);
            odb.cerrarStatement(ps);
            odb.cerrarConnection(conn);
        }
    }
    
    public void putLocality(Integer knkey, String locality){
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null; 
        String suma = "";
        String sentenciaSQL = "SELECT states FROM t_transitions where knkey = ?";
        String sentenciaSQL1 = "UPDATE t_transitions SET states = ? where knkey = ?";
        try {
            conn = odb.obtenerConexion("db");
            
            ps = conn.prepareStatement(sentenciaSQL);
            ps.setInt(1, knkey);
            rs = ps.executeQuery();
            
            if(rs.next()){
                if(rs.getString("states") == null)
                    suma = null;
                else
                    suma = rs.getString("states") + ", ";
            }
            
            ps = conn.prepareStatement(sentenciaSQL1);
            if(suma == null){
                ps.setString(1, locality);
            }
            else
                ps.setString(1, suma + locality);
            ps.setInt(2, knkey);
            ps.executeUpdate();
        } catch (SQLException ex) {
      
            throw new CstF2Exception("Error al obtener el branch desde la base de datos");
        } finally {
            odb.cerrarResultSet(rs);
            odb.cerrarStatement(ps);
            odb.cerrarConnection(conn);
        }
    }
    
    public String getLocality(Integer knkey){
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        String msj = "";
        String aviso = "";
        String sentenciaSQL1 = "SELECT states FROM t_transitions where knkey = ?";
        try {
            conn = odb.obtenerConexion("db");
            ps = conn.prepareStatement(sentenciaSQL1);
            ps.setInt(1, knkey);
            rs = ps.executeQuery();
            
            if(rs.next()){
                msj = rs.getString("states");
                
                if(msj == null)
                    return null;
                else{
                    aviso += msj + ", ";
                }
            }
        } catch (SQLException ex) {
         
            throw new CstF2Exception("Error al obtener el branch desde la base de datos");
        } finally {
            odb.cerrarResultSet(rs);
            odb.cerrarStatement(ps);
            odb.cerrarConnection(conn);
        }
        return aviso.substring(0, aviso.length()-2);
    }
    
    public String validateBranch(Integer knkey){
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        String sentenciaSQL = "SELECT confirmated FROM t_transitions where knkey = ?";
        String msj = "";
        Boolean con = false;
        String aviso = null;
        String local ="";

        try {
            conn = odb.obtenerConexion("db");
            ps = conn.prepareStatement(sentenciaSQL);
            ps.setInt(1, knkey);
            rs = ps.executeQuery();
            if (rs.next()) {
                do{
                    //msj = rs.getString("nombre");
                    con = rs.getBoolean("confirmated");
                    if(con){
                        local += msj + ", ";
                    }
                }while(rs.next());
            }
        } catch (SQLException ex) {
            
            throw new CstF2Exception("Error al obtener el branch desde la base de datos");
        } finally {
            odb.cerrarResultSet(rs);
            odb.cerrarStatement(ps);
            odb.cerrarConnection(conn);
        }
        if(!local.equals("")){
            local = local.substring(0, local.length()-2);
            aviso = "Las siguientes localidades ya fueron notificadas: " + local;
        }
        return aviso;
    }

    public boolean transitionExists(int knkey) {
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        boolean uploaded = false;
        String sentenciaSQL = "SELECT id FROM t_transitions WHERE knkey = ?";
        int index = 1;

        try {
            conn = odb.obtenerConexion("db");
            ps = conn.prepareStatement(sentenciaSQL);
            ps.setInt(index++, knkey);
            rs = ps.executeQuery();
            if (rs.next()) {
                uploaded = true;
            }
        } catch (SQLException ex) {
            
            throw new CstF2Exception("Error al obtener el Usuario desde la base de datos");
        } finally {
            odb.cerrarResultSet(rs);
            odb.cerrarStatement(ps);
            odb.cerrarConnection(conn);
        }

        return uploaded;
    }

    public boolean updateUploaded(String file, int knkey, String value) {
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        boolean uploaded = false;
        String sentenciaSQL = "UPDATE joindocumenttransition SET details = ? WHERE iddocument = (SELECT id FROM t_documents WHERE name = ?) AND idtransition = (SELECT id FROM t_transitions WHERE knkey = ?);";
        int index = 1;

        try {
            conn = odb.obtenerConexion("db");
            ps = conn.prepareStatement(sentenciaSQL);
            ps.setString(index++, value);
            ps.setString(index++, file);
            ps.setInt(index++, knkey);
            ps.executeUpdate();
        } catch (SQLException ex) {
            
            throw new CstF2Exception("Error al obtener el Usuario desde la base de datos");
        } finally {
            odb.cerrarResultSet(rs);
            odb.cerrarStatement(ps);
            odb.cerrarConnection(conn);
        }

        return uploaded;
    }

    public boolean updateUploaded(String file, int knkey) {
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        boolean uploaded = false;
        String sentenciaSQL = "UPDATE joindocumenttransition SET uploaded = TRUE WHERE iddocument = (SELECT id FROM t_documents WHERE name = ?) AND idtransition = (SELECT id FROM t_transitions WHERE knkey = ?);";
        int index = 1;

        try {
            conn = odb.obtenerConexion("db");
            ps = conn.prepareStatement(sentenciaSQL);
            ps.setString(index++, file);
            ps.setInt(index++, knkey);
            ps.executeUpdate();
        } catch (SQLException ex) {
            
            throw new CstF2Exception("Error al obtener el Usuario desde la base de datos");
        } finally {
            odb.cerrarResultSet(rs);
            odb.cerrarStatement(ps);
            odb.cerrarConnection(conn);
        }

        return uploaded;
    }

    public boolean fileUploaded(String file, int knkey) {
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        boolean uploaded = false;
        String sentenciaSQL = "SELECT id, uploaded FROM joindocumenttransition WHERE iddocument = (SELECT id FROM t_documents WHERE name = ?) AND idtransition = (SELECT id FROM t_transitions WHERE knkey = ?);";
        int index = 1;
        String upd = "";

        try {
            conn = odb.obtenerConexion("db");
            ps = conn.prepareStatement(sentenciaSQL);
            ps.setString(index++, file);
            ps.setInt(index++, knkey);

            rs = ps.executeQuery();
            if (rs.next()) {
                uploaded = true;
                upd = rs.getString("uploaded");
            }
           
        } catch (SQLException ex) {
            
            throw new CstF2Exception("Error al obtener el Usuario desde la base de datos");
        } finally {
            odb.cerrarResultSet(rs);
            odb.cerrarStatement(ps);
            odb.cerrarConnection(conn);
        }

        return uploaded;
    }
    
    public boolean verifyUploaded(String file, int knkey){
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        boolean uploaded = false;
        String sentenciaSQL = "SELECT id, uploaded FROM joindocumenttransition WHERE iddocument = (SELECT id FROM t_documents WHERE name = ?) AND idtransition = (SELECT id FROM t_transitions WHERE knkey = ?);";
        int index = 1;
        String upd = "";

        try {
            conn = odb.obtenerConexion("db");
            ps = conn.prepareStatement(sentenciaSQL);
            ps.setString(index++, file);
            ps.setInt(index++, knkey);

            rs = ps.executeQuery();
            if (rs.next()) {
                upd = rs.getString("uploaded");
            }
            
            if(file.equals("Customer Profile") && upd.equals("t")){
                return true;
            }
            if(file.equals("rfc") && upd.equals("t")){
                return true;
            }
            if(file.equals("R1") && upd.equals("t")){
                return true;
            }
            if(file.equals("R2") && upd.equals("t")){
                return true;
            }
            if(file.equals("Minimum Selling Rates") && upd.equals("t")){
                return true;
            }
            if(file.equals("Sales Quotation") && upd.equals("t")){
                return true;
            }
            if(file.equals("Rate Tracker") && upd.equals("t")){
                return true;
            }
            if(file.equals("ACON Debtor Number") && upd.equals("t")){
                return true;
            }
           
        } catch (SQLException ex) {
            
            throw new CstF2Exception("Error al obtener el Usuario desde la base de datos");
        } finally {
            odb.cerrarResultSet(rs);
            odb.cerrarStatement(ps);
            odb.cerrarConnection(conn);
        }

        return uploaded;
    }

    public TransitionBean obtenerTransitionBeanIdKnkeyByKnkey(TransitionBean transitionBean) {
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        String sentenciaSQL = TransitionSql.SELECCIONAR_IDKNKEY;
        int index = 1;

        try {
            conn = odb.obtenerConexion("db");
            ps = conn.prepareStatement(sentenciaSQL);
            ps.setInt(index++, transitionBean.getKnkey());

            rs = ps.executeQuery();
            transitionBean = AdaptadorTransition.obtenerTransitionBean(rs);
        } catch (SQLException ex) {
            
            throw new CstF2Exception("Error al obtener el Usuario desde la base de datos");
        } finally {
            odb.cerrarResultSet(rs);
            odb.cerrarStatement(ps);
            odb.cerrarConnection(conn);
        }
        return transitionBean;
    }

    public T_clientesDataFromStkBean obtenerDataFromTClientesSTK(TransitionBean transitionBean) {
        T_clientesDataFromStkBean t_clientesDataFromStkBean = new T_clientesDataFromStkBean();
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        String sentenciaSQL = TransitionSql.SELECCIONAR_DATAFROMKNKEYFROMSTK;
        int index = 1;

        try {
            conn = odb.obtenerConexion("db2");
            ps = conn.prepareStatement(sentenciaSQL);
            ps.setInt(index++, transitionBean.getKnkey());

            rs = ps.executeQuery();
            t_clientesDataFromStkBean = AdaptadorTransition.obtenerDataFromKnkeyFromStk(rs);
        } catch (SQLException ex) {
            
            throw new CstF2Exception("Error al obtener el Usuario desde la base de datos");
        } finally {
            odb.cerrarResultSet(rs);
            odb.cerrarStatement(ps);
            odb.cerrarConnection(conn);
        }
        return t_clientesDataFromStkBean;
    }

    public AsignIfownerStkBean obtenerIfOwnerFromSTK(TransitionBean transitionBean) {
        AsignIfownerStkBean asignIfownerStkBean = new AsignIfownerStkBean();
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        String sentenciaSQL = TransitionSql.SELECCIONAR_IFOWNERFROMKNKEY;
        int index = 1;

        try {
            conn = odb.obtenerConexion("db2");
            ps = conn.prepareStatement(sentenciaSQL);
            ps.setInt(index++, transitionBean.getKnkey());

            rs = ps.executeQuery();
            asignIfownerStkBean = AdaptadorTransition.obtenerIfowner(rs);
        } catch (SQLException ex) {
            
            throw new CstF2Exception("Error al obtener el Usuario desde la base de datos");
        } finally {
            odb.cerrarResultSet(rs);
            odb.cerrarStatement(ps);
            odb.cerrarConnection(conn);
        }
        return asignIfownerStkBean;
    }

    public TransitionBean obtenerDataFromTransition(TransitionBean transitionBean) {
        //TransitionBean transitionBean = new TransitionBean();
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        String sentenciaSQL = TransitionSql.SELECCIONAR_DATATRANSITION;
        int index = 1;

        try {
            conn = odb.obtenerConexion("db");
            ps = conn.prepareStatement(sentenciaSQL);
            //ps.setInt(index++, transitionBean.getKnkey());

            rs = ps.executeQuery();
            transitionBean = AdaptadorTransition.obtenerDataTransition(rs);
        } catch (SQLException ex) {
            
            throw new CstF2Exception("Error al obtener el Usuario desde la base de datos");
        } finally {
            odb.cerrarResultSet(rs);
            odb.cerrarStatement(ps);
            odb.cerrarConnection(conn);
        }
        return transitionBean;
    }

    public TransitionBean obtenerStatus(Integer knkey) {
        TransitionBean transitionBean = new TransitionBean();
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        String sentenciaSQL = TransitionSql.SELECCIONAR_STATUSTRANSITION;
        int index = 1;

        try {
            conn = odb.obtenerConexion("db");
            ps = conn.prepareStatement(sentenciaSQL);

            ps.setInt(index++, knkey);

            rs = ps.executeQuery();
            transitionBean = AdaptadorTransition.obtenerStatusTransition(rs);
        } catch (SQLException ex) {
            
            throw new CstF2Exception("Error al obtener el Usuario desde la base de datos");
        } finally {
            odb.cerrarResultSet(rs);
            odb.cerrarStatement(ps);
            odb.cerrarConnection(conn);
        }
        return transitionBean;
    }

    public TransitionBean obtenerStatusImplementation(Integer knkey) {
        TransitionBean transitionBean = new TransitionBean();
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        String sentenciaSQL = TransitionSql.SELECCIONAR_STATUSIMPLEMENTATION;
        int index = 1;

        try {
            conn = odb.obtenerConexion("db");
            ps = conn.prepareStatement(sentenciaSQL);

            ps.setInt(index++, knkey);

            rs = ps.executeQuery();
            transitionBean = AdaptadorTransition.obtenerStatusImplementation(rs);
        } catch (SQLException ex) {
            
            throw new CstF2Exception("Error al obtener el Usuario desde la base de datos");
        } finally {
            odb.cerrarResultSet(rs);
            odb.cerrarStatement(ps);
            odb.cerrarConnection(conn);
        }
        return transitionBean;
    }

    public TransitionBean obtenerDataFromTransitionIdKnkey(TransitionBean transitionBean) {
        //TransitionBean transitionBean = new TransitionBean();
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        String sentenciaSQL = TransitionSql.SELECCIONAR_DATATRANSITIONIDKNKEY;
        int index = 1;

        try {
            conn = odb.obtenerConexion("db");
            ps = conn.prepareStatement(sentenciaSQL);
            ps.setInt(index++, transitionBean.getKnkey());

            rs = ps.executeQuery();
            transitionBean = AdaptadorTransition.obtenerDataTransitionIdKnkey(rs);
        } catch (SQLException ex) {
            
            throw new CstF2Exception("Error al obtener el Usuario desde la base de datos" + ex);
        } finally {
            odb.cerrarResultSet(rs);
            odb.cerrarStatement(ps);
            odb.cerrarConnection(conn);
        }
        return transitionBean;
    }

    public DocumentsBean obtenerDocumentName(TransitionBean transitionBean) {
        DocumentsBean documentsBean = new DocumentsBean();

        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        String sentenciaSQL = TransitionSql.SELECCIONAR_DOCUMENTNAME;
        int index = 1;

        try {
            conn = odb.obtenerConexion("db");
            ps = conn.prepareStatement(sentenciaSQL);
            ps.setInt(index++, transitionBean.getId());

            rs = ps.executeQuery();
            documentsBean = AdaptadorTransition.obtenerDocumentName(rs);
        } catch (SQLException ex) {
            
            throw new CstF2Exception("Error al obtener el Usuario desde la base de datos");
        } finally {
            odb.cerrarResultSet(rs);
            odb.cerrarStatement(ps);
            odb.cerrarConnection(conn);
        }
        return documentsBean;
    }













  
    public static void main(String args[]) {
        TransitionServer transitionServer = new TransitionServer();
        TransitionBean transitionBean = new TransitionBean();

        transitionBean.setKnkey(10475);
        T_clientesDataFromStkBean tb = new T_clientesDataFromStkBean();
        tb = transitionServer.obtenerDataFromTClientesSTK(transitionBean);
        System.out.println("" + tb.getCompanyname());

        /*     --------------------------------------------     */

        transitionServer = new TransitionServer();
        transitionBean = new TransitionBean();

        transitionBean.setKnkey(1753);
        AsignIfownerStkBean tb2 = new AsignIfownerStkBean();
        tb2 = transitionServer.obtenerIfOwnerFromSTK(transitionBean);
        System.out.println("" + tb2.getIfownwer());

        /*     --------------------------------------------     */
        transitionServer = new TransitionServer();
        transitionBean = new TransitionBean();

        transitionBean.setKnkey(10475);
        DocumentsBean docsBean = new DocumentsBean();
        transitionBean = transitionServer.obtenerTransitionBeanIdKnkeyByKnkey(transitionBean);
        docsBean = transitionServer.obtenerDocumentName(transitionBean);
        System.out.println("" + docsBean.getName());

        /*     --------------------------------------------     */

//        transitionServer = new TransitionServer();
//        transitionBean = new TransitionBean();
//
//        transitionBean.setKnkey(10475);
//        JoindocumenttransitionBean joindocumenttransitionBean = new JoindocumenttransitionBean();
//        transitionBean = transitionServer.obtenerTransitionBeanIdKnkeyByKnkey(transitionBean);
//        joindocumenttransitionBean = transitionServer.obtenerJoindocumenttransitionData(transitionBean);
//        System.out.println("" + joindocumenttransitionBean.getVobo());

        /*     --------------------------------------------     */

//        transitionServer = new TransitionServer();
//        transitionBean = new TransitionBean();
//
//        transitionBean.setKnkey(10475);
//        PersonalBean personalBean = new PersonalBean();
//        transitionBean = transitionServer.obtenerTransitionBeanIdKnkeyByKnkey(transitionBean);
//        personalBean = transitionServer.obtenerDataPersonal(transitionBean);
//        System.out.println("" + personalBean.getEmail());

        /*     --------------------------------------------     */


    }
    
    public void actualizarDetailsEnJoindocumenttransition(String detailsnum, Integer documentid, Integer transitionId) {

        Connection conn = null;
        PreparedStatement ps = null;
        // ResultSet rs = null;
        String sentenciaSQL = TransitionSql.UPDATE_DETAILS_EN_JOINDOCUMENTTRANSITION;
        int index = 1;

        try {
            conn = odb.obtenerConexion("db");
            ps = conn.prepareStatement(sentenciaSQL);

            ps.setString(index++, detailsnum);
            ps.setInt(index++, documentid);
            ps.setInt(index++, transitionId);


            ps.executeUpdate();

        } catch (SQLException ex) {
            
            throw new CstF2Exception("Error al obtener el Usuario desde la base de datos");
        } finally {
            //odb.cerrarResultSet(rs);
            odb.cerrarStatement(ps);
            odb.cerrarConnection(conn);
        }

    }

}
